﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WorkstationDashboard
{
    public partial class WorkstationHost : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            treeView.SelectedNodeChanged += new EventHandler(treeView_SelectedNodeChanged);
        }

        void treeView_SelectedNodeChanged(object sender, EventArgs e)
        {
            int nodeDepth = treeView.SelectedNode.Depth;
            string nodeValue = treeView.SelectedValue;
            switch (nodeDepth)
            {
                case 0:
                    Response.Redirect("ContentRoot.aspx", true);
                    break;
                case 1:
                    Response.Redirect("ContentGroup.aspx?id=" + nodeValue, true);
                    break;
                case 2:
                    Response.Redirect("ContentWorkstation.aspx?id=" + nodeValue, true);
                    break;
                case 3:
                    Response.Redirect("ContentDevice.aspx?id=" + nodeValue, true);
                    break;
                default:
                    break;
            }
        }

        public TreeView WorkstationTreeView { get { return treeView; } }
    }
}
